package com.jhws.core.spring.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * 菜单拦截
 *
 * @author xiaokek
 * @since 2015年12月27日 上午10:31:55
 */
public class MenuInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

		return true;
	}
	
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		String menuPare = request.getParameter("menuPare");
		if(StringUtils.isNotBlank(menuPare)){
			request.setAttribute("menuPare", menuPare);
		}
		
		String menuChild = request.getParameter("menuChild");
		if(StringUtils.isNotBlank(menuChild)){
			request.setAttribute("menuChild", menuChild);
		}
		
	}

}
